package com.example.mytestdemo.customviewbook.four.sliding.harvic.slidingconflict.testtouchevent;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.LinearLayoutCompat;

import com.example.mytestdemo.R;

public class SecondActivity extends AppCompatActivity {

    private Button bt;
    private LinearLayoutCompat ll_contain;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_four_second_main);
        bt= findViewById(R.id.second_activity);
        ll_contain = findViewById(R.id.ll_contain);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("SecondActivity", "hhh onClick: ");
            }
        });

        ll_contain.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.d("TAG", "onTouchEvent onTouch: ");
                return false;//返回true会导致activity的onTouchEvent方法被拦截，
                // 因为ontouch方法在onTouchEvent之前被调用
            }
        });
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        LogHelper.onLog("SecondActivity dispatchTouchEvent",event);
//        return false;
        return super.dispatchTouchEvent(event);
//        return true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        LogHelper.onLog("SecondActivity onTouchEvent",event);
//        return super.onTouchEvent(event);
        return true;
    }
}
